<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp" %>
  <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp" %>
  <%@ include file="/WEB-INF/include/submenu.jsp" %>

  <div class="container-fluid ms-container has-ms-sidemenu">

    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">司机信息管理</li>
    </ol>

    <div class="ms-content-layout">

      <ul class="nav nav-tabs ms-nav-tabs" role="tablist">
        <li role="presentation" class="${!bind ? 'active' : ''}">
          <a href="${ctx.host}/relation-drivers?bind=false">未绑定</a>
        </li>
        <li role="presentation" class="${bind ? 'active' : ''}">
          <a href="${ctx.host}/relation-drivers?bind=true">已绑定</a>
        </li>
      </ul>

      <div class="ms-operation-bar no-margin no-bottom-border clearfix">
        <div class="ms-operation-group">
          <div class="pull-right">
            <a href="${ctx.host}/relation-drivers/search?bind=${bind}" data-target="#search" data-toggle="modal" class="btn ms-btn ms-btn-blue">
              <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
            </a>
          </div>
        </div>
      </div>

      <table class="table table-hover ms-table">
        <thead>
	        <tr>
	          <th>序号</th>
	          <th>公司名称</th>
	          <th>姓名</th>
	          <th>性别</th>
	          <th>工号</th>
	          <th>身份证号</th>
	          <th>现任职务</th>
	          <th>所属交通工具</th>
	          <th>审核状态</th>
	          <th>是否绑定车辆</th>
	          <th class="text-center">操作</th>
	        </tr>
        </thead>

        <tbody>
	        <c:forEach items="${drivers}" var="driver" varStatus="ordinal">
	          <tr>
	            <td>${ordinal.count}</td>
	            <td>${driver.supplier.name}</td>
	            <td>${driver.name}</td>
	            <td>${empty driver.gender ? '' : persist.masterData('SEX', driver.gender)}</td>
	            <td>${driver.code}</td>
	            <td>${driver.citizenCode}</td>
	            <td>${empty driver.dutyId ? '' : persist.masterData('TRUCK_POSITION', driver.dutyId)}</td>
	            <td>${empty driver.vehicleId ? '' : persist.vehicle(driver.vehicleId).name}</td>
	            <td>${driver.status.description}</td>
	            <td>${driver.bind ? '是' : '否'}</td>
	            <td class="text-center">
	              <c:choose>
	                <c:when test="${driver.bind}">
	                  <a href="${ctx.host}/relation-drivers/${driver.id}/unbind" data-target="#unbind" data-toggle="modal">解绑</a>
	                </c:when>
	                <c:otherwise>
	                  <a href="${ctx.host}/relation-drivers/${driver.id}/create">绑定</a>&nbsp;&nbsp;
	                </c:otherwise>
	              </c:choose>
	            </td>
	          </tr>
	        </c:forEach>
        </tbody>
        
	      <tfoot>
	        <tr>
		        <td colspan="12">
		          <div class="pull-left">
		            <jsp:include page="/WEB-INF/include/page.jsp">
		              <jsp:param name="url" value="relation-drivers"/>
		              <jsp:param name="queryString" value="${queryString}"/>
		            </jsp:include>
		          </div>
		        </td>
		      </tr>
	      </tfoot>
	      
     </table>

    </div>
  </div>
    
  <%@ include file="/WEB-INF/include/script.jsp" %>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/supplier/management/relation/relation-driver-list.js"/>
  <script type="text/javascript">
    require(['page/supplier/management/relation/relation-driver-list'], function (page) {
      page.init()
    })
  </script>

</body>
</html>